package com.jml.Configuration注解001.config;

import com.jml.Configuration注解001.entity.UserEntity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Service;


@Configuration
//只扫描有@Service的类
@ComponentScan(
        value = "com.jml.Configuration注解001",
        includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Service.class)},
        useDefaultFilters = false)
/*
不扫描@Service的类
@ComponentScan(value = "com.jml.Configuration注解", excludeFilters =
        {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Service.class)}, useDefaultFilters = true)
*/
public class MySpringConfig {

    /*
    
        includeFilters 包含的扫包范围 必须有这些 排除这些没有
        @Configuration 等于 spring xml
        <bean class="UserEntity" id="方法名称" >
        将该包下 的 只要有类上加上@service 注解的 注入到spring容器
      
     */


    /*等价于bean标签，方法名字等价于id属性*/
    @Bean
    public UserEntity userEntity() {
        return new UserEntity("jml", 21);
    }
    /**
     *  记住一点 如果需要将外部的jar包注入spring容器中 @Bean
     */
}
